package com.bosssoft.trainee.controller;

import com.bosssoft.trainee.common.annotation.Description;
import com.bosssoft.trainee.mbg.po.Position;
import com.bosssoft.trainee.mbg.result.CommonResult;
import com.bosssoft.trainee.mbg.vo.QueryVO;
import com.bosssoft.trainee.service.PositionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Author: wuxin
 * @Project: rbac-SpringCloud
 * @Date: 2022/7/19
 * @Description:
 */
@RestController
@RequestMapping("/pos")
public class PositionController {
    @Autowired
    PositionService positionService;
    @Description("根据id批量获取Position")
    @GetMapping("/getPos")
    public CommonResult<Position[]> getPos(@RequestParam("ids") List<Integer> ids){
        List<Position> list = positionService.getPositions(ids);
        return CommonResult.success(list.toArray(new Position[0]));
    }

    @Description("获取职位列表")
    @PostMapping("/list")
    public CommonResult<Position[]> list(@RequestBody QueryVO<Position> queryVO){
        List<Position> list = positionService.getList();
        return CommonResult.success(list.toArray(list.toArray(new Position[0])));
    }

    @Description("根据id删除职位")
    @GetMapping("/deleteById")
    public CommonResult<Integer> deleteById(@RequestParam("id")Integer id){
        return CommonResult.success(positionService.deleteById(id));
    }
}
